package com.example.demo.study.lambda;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @Author：zhoutaoming
 * @name：LambdaTest1
 * @Date：2023/10/28 18:03
 * @Version 1.0
 */
public class LambdaCollections {
    public static void main(String[] args) {
        List<String> list = Arrays.asList("hello","tom","apple","bbc");
        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });

        //使用lambda表达式
        Collections.sort(list,(String s1,String s2) ->{
            return s1.compareTo(s2);
        });

        Collections.sort(list,(s1,s2)->s1.compareTo(s2));

        System.out.println(list);

    }
}
